package com.zheng.wc.rpc.service.impl;

import com.zheng.common.annotation.BaseService;

import com.zheng.oa.common.constant.enums.OaStatus;
import com.zheng.upms.dao.model.UpmsUser;
import com.zheng.upms.rpc.api.UpmsApiService;
import com.zheng.wc.dao.model.WcPlan;
import com.zheng.wc.dao.mapper.WcPlanMapper;
import com.zheng.wc.rpc.api.WcPlanService;
import com.zheng.common.base.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author likun
 * @since 2018-03-30
 */
@Service
@Transactional(rollbackFor = Exception.class)
@BaseService
public class WcPlanServiceImpl extends BaseServiceImpl<WcPlanMapper, WcPlan> implements WcPlanService {
    @Autowired
    private WcPlanMapper planMapper;

    public boolean deletePlans(String ids) throws Exception {
        String[] idArray = ids.split("-");
        for (String idStr : idArray) {
            WcPlan plan = selectById(Integer.parseInt(idStr));
            plan.setStatus(OaStatus.DELETED.getKey());
            updateById(plan);
        }
        return true;
    }

    public List<Map<String, Object>> selectPlanMaps(WcPlan plan) {
        return planMapper.selectPlanMaps(plan);
    }

    public Integer selectPlanMapsCount(WcPlan plan) {
        return planMapper.selectPlanMapsCount(plan);
    }

    public Map<String, Object> selectPlan(Integer id) {
        return planMapper.selectPlan(id);
    }
}
